Date.prototype.convert = function(format) {
    var args = {
        "M+": this.getMonth() + 1,
        "d+": this.getDate(),
        "h+": this.getHours(),
        "m+": this.getMinutes(),
        "s+": this.getSeconds(),
        "q+": Math.floor((this.getMonth() + 3) / 3), //quarter
        "S": this.getMilliseconds()
    };
    if(/(y+)/.test(format))
        format = format.replace(RegExp.$1, (this.getFullYear() + "").substr(4 - RegExp.$1.length));
    for(var i in args) {
        var n = args[i];
        if(new RegExp("(" + i + ")").test(format))
            format = format.replace(RegExp.$1, RegExp.$1.length == 1 ? n : ("00" + n).substr(("" + n).length));
    }
    return format;
};

var deepCopy = function(json) {
    if(typeof json == 'number' || typeof json == 'string' || typeof json == 'boolean' || json == null) {
        return json;
    } else if(typeof json == 'object') {
        if(json instanceof Array) {
            var newArr = [],
                i, len = json.length;
            for(i = 0; i < len; i++) {
                newArr[i] = arguments.callee(json[i]);
            }
            return newArr;
        } else {
            var newObj = {};
            for(var name in json) {
                newObj[name] = arguments.callee(json[name] === 0 ? 0 : json[name]);
            }
            return newObj;
        }
    }
};

var typeOf = function (obj) {
    var toString = Object.prototype.toString;
    var map = {
        '[object Boolean]': 'boolean',
        '[object Number]': 'number',
        '[object String]': 'string',
        '[object Function]': 'function',
        '[object Array]': 'array',
        '[object Date]': 'date',
        '[object RegExp]': 'regExp',
        '[object Undefined]': 'undefined',
        '[object Null]': 'null',
        '[object Object]': 'object'
    };
    return map[toString.call(obj)];
};